import request from "@/utils/request";
import {
  GetTrademarkListApiResponse,
  TrademarkItem,
} from "./modules/trademarkModules";

enum Api {
  getTrademarkListUrl = "/admin/product/baseTrademark",
  addTradeMarkUrl = "/admin/product/baseTrademark/save",
  editTradeMarkUrl = "/admin/product/baseTrademark/update",
  deleteOneTrademark = "/admin/product/baseTrademark/remove/",
}

/**
 * 获取品牌管理列表
 * @param page 当前页数
 * @param limit 一页几条
 * @returns GetTrademarkListApi
 */
export const getTrademarkListApi = (page: number, limit: number) =>
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  request.get<any, GetTrademarkListApiResponse>(
    Api.getTrademarkListUrl + `/${page}/${limit}`
  );

/**
 * 添加一个品牌信息
 * @param tmName 品牌名字
 * @param logoUrl 图片地址
 * @returns null
 */
export const addTradeMarkApi = (tmName: string, logoUrl: string) =>
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  request.post<any, null>(Api.addTradeMarkUrl, { tmName, logoUrl });

/**
 * 修改品牌
 * @param trademark 品牌参数，id,tmName,logoUrl
 * @returns null
 */
export const editTradeMarkApi = (trademark: TrademarkItem) =>
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  request.put<any, null>(Api.editTradeMarkUrl, trademark);

/**
 * 删除一条品牌信息
 * @param id 商品id
 * @returns null
 */
export const deleteOneTrademarkApi = (id: number) =>
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  request.delete<any, null>(Api.deleteOneTrademark + `${id}`);
